package com.example.library

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.orm.jpa.vendor.Database
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter

/**
 * @author xiang
 * @Date 2022/9/9 11:09
 **/

@Configuration
class HibernateConfig {

    companion object {
        private const val TAG = "HibernateConfig"
    }

    @Bean
    fun jpaVendorAdapter(): HibernateJpaVendorAdapter {
        Log.i(TAG, "jpaVendorAdapter")
        return HibernateJpaVendorAdapter().apply {
            setDatabase(Database.MYSQL)
            setShowSql(true)
            setGenerateDdl(true)
            setDatabasePlatform("org.hibernate.dialect.MySQL8Dialect")
        }
    }

}